function count_same_elements(collection) {
  //在这里写入代码
  let arr = [] ;
  let obj = {} ;
  for(let item of collection){
    if(!obj[item]){
       obj[item] = {} ;
       obj[item].key = item ;
       obj[item].count = 1 ;
    }else{
      obj[item].count ++ ;
    }
  }
  for(let value in obj){
    arr.push(obj[value]) ;
  }
  return arr ;
}

module.exports = count_same_elements;
